<div class="col-md-9">
	<div class="row">
		<?php include("html-includes/common/carousel.php"); ?>
	</div>
	
	<div class="row" id="content">
		<div class="heading">
			<h2><?php echo $selectedCategory["alt_title"]; ?></h2>
			<div class="links">
				<a href="<?php echo site_url() . $selectedCategory["url"]; ?>" title="<?php echo $selectedCategory["name"]; ?>"><?php echo translate("vezi_toate_categoriile_de_mobilier");?></a>
			</div>
			<div class="clearfix"></div>
		</div>
		<div class="clearfix"></div>
		<?php foreach($selectedCategory["children"] as $category): ?>                    
			<div class="col-md-3">
				<div class="row">
					<h3><?php echo $category["name"]; ?></h3>
					<ul>
						<?php foreach($category["children"] as $subCategory): ?>
							<li><a href="<?php echo site_url(). $subCategory["url"]; ?>" title="<?php echo $subCategory["name"]; ?>"><?php echo $subCategory["name"]; ?></a></li>
						<?php endforeach; ?>
					</ul>
				</div>
			</div>
		<?php endforeach; ?>
		<div class="clearfix"></div>
		
		<?php
		 	$products = filter_products(false, 4, null,$settings["number_of_products"],"id","asc",null,null); 
			if(isset($products[0]["num_rows"]) && $products[0]["num_rows"] > 0):
			$totalPages = ceil(($products[0]["num_rows"]/$settings["number_of_products"]) -1);
		?>
			<div class="heading">
				<h2><?php echo translate("oferte_speciale_si_reduceri_la_mobila")?></h2>
				<div class="links">
					<a href="<?php echo $site_pages["promotions"]["url"];?>" title="<?php echo $site_pages["promotions"]["name"];?>"><?php echo translate("mai_multe_superoferte"); ?></a>
					<?php if($products[0]["num_rows"] > $settings["number_of_products"]): ?>
						<a href="#" title="<?php echo translate("next_page"); ?>" class="next" page="1"><span class="glyphicon glyphicon-chevron-left"></span></a>
						<a href="#" title="<?php echo translate("prev_page");?>" class="prev" page="<?php echo $totalPages;?>"><span class="glyphicon glyphicon-chevron-right"></span></a>
					<?php endif; ?>
				</div>
				
				<div class="clearfix"></div>
			</div>
			<div class="productHolder cols-<?php echo $settings["number_of_products"]; ?>" type="4" items="<?php echo $settings["number_of_products"];?>" orderby="id" sort_order="asc">
				<?php
					if($settings["number_products"] == 1)
					{
						include("html-includes/common/product-detail-list.php"); 
					}
					else 
					{
						include("html-includes/common/product-list.php"); 
					}
				?>
				<div class="clearfix"></div>
			</div>
			
			<div class="clearfix"></div>
		<?php endif; ?>
		
		<?php
		 	$products = filter_products(false, false, null,$settings["number_of_products"],"view_count","desc",null,null); 
			if(isset($products[0]["num_rows"]) && $products[0]["num_rows"] > 0):
				$totalPages = ceil(($products[0]["num_rows"]/$settings["number_of_products"]) -1);
		?>
		
			<div class="heading">
				<h2><?php echo translate("top_produse_vizualizate"); ?></h2>
				<div class="links">
					<a href="<?php echo $site_pages["popular_products"]["url"];?>" title="<?php echo $site_pages["popular_products"]["title"];?>"><?php echo translate("mai_multe_produse_populare"); ?></a>
					<a href="#" title="<?php echo translate("next_page"); ?>" class="next" page="1"><span class="glyphicon glyphicon-chevron-left"></span></a>
							<a href="#" title="<?php echo translate("prev_page");?>" class="prev" page="<?php echo $totalPages;?>"><span class="glyphicon glyphicon-chevron-right"></span></a>
				</div>
				
				<div class="clearfix"></div>
			</div>
			<div class="productHolder cols-<?php echo $settings["number_of_products"]; ?>" type="0" items="<?php echo $settings["number_of_products"];?>" orderby="view_count" sort_order="desc">
				<?php
					$show = "views";
					if($settings["number_products"] == 1)
					{
						include("html-includes/common/product-detail-list.php"); 
					}
					else 
					{
						include("html-includes/common/product-list.php"); 
					}
				?>
				<div class="clearfix"></div>
			</div>
			
			<div class="clearfix"></div>
		<?php endif; ?>
		
		<?php
			$events = get_latest_events(3);
			
			if(count($events) > 0):
		?>
		
		<div class="col-md-6">
			<div class="row">
				
				<div class="heading">
					<h2><?php echo translate("expozitii_mobila")?></h2>
					<div class="links">
						<a href="<?php echo $site_pages["events"]["url"]; ?>" title="<?php echo $site_pages["events"]["name"]; ?>"><?php echo translate("vezi_calendar")?></a>
					</div>
					
					<div class="clearfix"></div>
				</div>
				<?php include("html-includes/common/event-list.php"); ?>
			</div>
		</div>
		<?php endif; ?>
		
		<?php
			$companies = getCompanies("creation_date","asc", 5);
			if($companies):
		 ?>
		
			<div class="col-md-6">
				
				<div class="heading">
					<h2><?php echo translate("newest_companies"); ?></h2>
					<div class="links">
						<a href="<?php echo $site_pages["companies"]["url"]; ?>" title="<?php echo $site_pages["companies"]["name"]; ?>"><?php echo strtolower(translate("read_more")); ?></a>
					</div>
					
					<div class="clearfix"></div>
				</div>
				
				<table id="companiesTable" class="table table-responsive table-condensed table-hover" border="0"> 
					<?php foreach($companies as $company): ?>
						<tr>
							<td class="name"><a href="<?php echo $site_pages["companies"]["url"] . $company["url"]; ?>.html" title="<?php echo $company["name"]; ?>"><?php echo $company["name"]; ?></a></td>
							<td><span><?php echo $company["city_name"]; ?></span></td>
							<td>
								<?php
									if($company["business_type"] == 1)
									{
										$businessType = translate("producator");
									}
									elseif($company["business_type"] == 2)
									{
										$businessType = translate("distribuitor");
									}
									elseif($company["business_type"] == 3)
									{
										$businessType = translate("furnizor");
									}
									
									echo ucfirst($businessType);
								?>
							</td>
						</tr>
					<?php endforeach; ?>
					
				</table>
				
			</div>
			<div class="clearfix"></div>
		<?php endif; ?>
	</div>
</div>

<!-- SIDEBAR -->
<?php include("html-includes/homepage/items/sidebar.php"); ?>
<!-- END SIDEBAR-->
<div class="clearfix"></div>
